function login()
{
    $('button').click(
        function(e)
        {
            e.preventDefault();
            
            $('button').attr('disabled', 'disabled');
            
            var username = document.getElementById('l_username').value;
            var password = document.getElementById('l_password').value;
            
            $.post(
                base_url + 'ajax_users/login',
                {username:username, password:password},
                function(data)
                {
                    $('#login_error').hide();
                    if(data.error == 0)
                    {
                        window.location.replace(base_url + '/');
                    }
                    else
                    {
                        $('#login_error_msg').html('Login failed! Username or password is incorrect!');
                        $('#login_error').show();
                        $('#login_error').effect("shake", { times:3, distance:5, direction:'down' }, 100);

                        setTimeout(function(){$('button').removeAttr('disabled');}, 1000);
                    }
                }, 'json'
            );
        }
    );
}